package com.example.plugin.event;

import android.app.Activity;
import android.content.IntentFilter;
import android.os.Bundle;
import com.example.plugin.API;
import com.example.plugin.APP;
import static com.example.plugin.APP.ACTION_GROUPEVENT_RECEIVE;
import static com.example.plugin.APP.ACTION_QQMESSAGE_RECEIVE;
import static com.example.plugin.APP.ACTION_RAWMESSAGE_RECEIVE;
import static com.example.plugin.APP.groupEventReceiver;
import static com.example.plugin.APP.qqmessageReceiver;
import static com.example.plugin.APP.rawmessageReceiver;
import static com.example.plugin.APP.pansy;

/**
 * 插件启用时调用
 */
public class PluginEnableActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //注册QQ消息广播
        if(qqmessageReceiver==null){
            qqmessageReceiver=new QQMessageReceiver();
            IntentFilter intentFilter=new IntentFilter();
            intentFilter.addAction(ACTION_QQMESSAGE_RECEIVE);
            getApplicationContext().registerReceiver(qqmessageReceiver,intentFilter);
        }
        //注册群事件广播
        if(groupEventReceiver==null){
            groupEventReceiver=new GroupEventReceiver();
            IntentFilter intentFilter=new IntentFilter();
            intentFilter.addAction(ACTION_GROUPEVENT_RECEIVE);
            getApplicationContext().registerReceiver(groupEventReceiver,intentFilter);
        }
        //注册原始消息广播
        /*if(rawmessageReceiver==null){
            rawmessageReceiver=new RawMessageReceiver();
            IntentFilter intentFilter=new IntentFilter();
            intentFilter.addAction(ACTION_RAWMESSAGE_RECEIVE);
            getApplicationContext().registerReceiver(rawmessageReceiver,intentFilter);
        }*/
        //实例化API类
        if(pansy==null)
            pansy=new API(APP.PACKAGE_NAME);
        finish();
    }
}
